﻿@model Bananer
@{
    ViewBag.Title = "Index";
}
<h2 style="color:red;">Quản Lý Bananer</h2>
<div role="tabpanel">

    <!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#edit" aria-controls="edit" role="tab" data-toggle="tab">Thêm Bananer &nbsp;<span class="glyphicon glyphicon-home"></span></a></li>
        <li role="presentation"><a href="#list" aria-controls="list" role="tab" data-toggle="tab">Danh sách Bananer &nbsp; <span class="glyphicon glyphicon-plus"></span></a></li>
    </ul>

    <!-- Tab panes -->
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active" id="edit">
            <h4>@Html.ValidationSummary()</h4>
            @using (Html.BeginForm("Insert", "Banane",
    FormMethod.Post, new { enctype = "multipart/form-data" }))
            {
                @Html.HiddenFor(b=>b.Id)
                <div class="row">
                    <div class="col-md-4">
                        <div class="form-group">
                            <div>Tên Bananer</div>
                            @Html.TextBoxFor(c => c.Name, new { @class = "form-control" })
                           
                        </div>

                        <div class="form-group">
                            <div>Vị Trí</div>
                            @Html.TextBoxFor(c => c.Position, new { @class = "form-control" })
                        </div>
                        <div class="form-group">
                            <div>Link</div>
                            @Html.TextBoxFor(c => c.Link, new { @class = "form-control" })
                        </div>

                        <div class="form-group">
                            <div>Trạng Thái</div>
                            @Html.CheckBoxFor(c => c.Status)
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="form-group">
                            <div>Logo</div>
                            <img style="width:130px;height:150px;" src="/images/bananer/@Model.Images" /><br />
                            <input type="file" name="UpPhoto" />
                            @Html.HiddenFor(s => s.Images)
                        </div>
                  
                    </div>
                </div>






                <div class="form-group">
                    <div></div>
                    <div>
                        <button onclick="form.action = '/Admin/Banane/Insert'" class="btn btn-default">Insert</button>
                        @if (Model.Id != 0)
                        {
                            <button onclick="form.action = '/Admin/Banane/Update'" class="btn btn-default">Update</button>
                                 <a href="/Admin/Banane/Delete/@Model.Id" onclick="return Xoa();" class="btn btn-default">Delete</a>
                        }
                        <a href="/Admin/Banane/Index" class="btn btn-default">Reset</a>
                    </div>
                </div>
            }
        </div>
        <div role="tabpanel" class="tab-pane" id="list">
            <br/><br />
            <table class="table table-hover ">
                <tr>
                    <th>Id</th>
                    <th>Tên Bananer</th>
                    <th>Link</th>
                    <th>Vị trí</th>
                    <th>Logo</th>
                    <th>Trạng Thái</th>
                    <th></th>
                </tr>
                @foreach (var c in ViewBag.Bananers)
                {
                    <tr>
                        <td>@c.Id</td>
                        <td>@c.Name</td>
                        <td>@c.Link</td>
                        <td>@c.Position</td>
                        <td>
                            <img style="width:100px;height:50px;" src="~/images/bananer/@c.Images" />
                        </td>

                        <td>@c.Status</td>

                        <td>
                            <a href="/Admin/Banane/Edit/@c.Id"
                               class="btn btn-default">Edit</a>
                            <a href="/Admin/Banane/Delete/@c.Id" onclick="return Xoa();" class="btn btn-default">Delete</a>
                        </td>
                    </tr>
                }
            </table>
        </div>
    </div>

</div>

@section scripts{
    <script>
    function Xoa() {
        var ok = confirm("Có chắc chắn xóa mẫu tin có mã  không?");
        if (ok == true) {
            window.location.href = "/Admin/Banane/Delete/@Model.Id";
        } else {
            return false;
        }
    }
    </script>
     
   
    
  }